<?php 
class Zendvn_CutString{
	function cut($str, $len) {
		$str = trim($str);
		if (strlen($str) <= $len) return $str;
		$str = substr($str, 0, $len);
		if ($str != "") {
			if (!substr_count($str, " ")) return $str." ...";
			while (strlen($str) && ($str[strlen($str) - 1] != " ")) $str = substr($str, 0, -1);
			$str = substr($str, 0, -1)." ...";
		}
		return $str;
	}
	 function cutchars($tr,$start,$end =null){
	           $tr=trim($tr);
	           $trs = explode(" ",$tr);
	           $count= count($trs);
	           if($end==null || $end > ($count-1) ){
	            $end =$count-1;
	           }
	            $result= array();
	          for($i =$start; $i<($end+1); $i++){
	                $result[]=$trs[$i];
	            }
	            return implode(" ",$result);
	        }
}
?>